package com.guyan.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * ClassName： ResultVo
 * Date： 2021/5/28 11:39
 *
 * @author 孤焰
 * @version 1.0
 **/

@NoArgsConstructor
@Data
public class ResultVo {
    private Integer code;
    private String message;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    public static ResultVo success() {
        ResultVo resultVo = new ResultVo();
        resultVo.code = 200;
        resultVo.message = "成功";

        return resultVo;
    }

    public static ResultVo success(Object data) {
        ResultVo resultVo = new ResultVo();
        resultVo.code = 200;
        resultVo.message = "成功";
        resultVo.data = data;

        return resultVo;
    }

    public static ResultVo success(Object data, String message) {
        ResultVo resultVo = new ResultVo();
        resultVo.code = 200;
        resultVo.message = message;
        resultVo.data = data;

        return resultVo;
    }

    public static ResultVo error(Integer code, String message) {
        ResultVo resultVo = new ResultVo();
        resultVo.code = code;
        resultVo.message = message;

        return resultVo;
    }
}
